package com.ambulance.project.biz.controller.manager;

import com.ambulance.common.utils.poi.ExcelUtil;
import com.ambulance.framework.aspectj.lang.annotation.Log;
import com.ambulance.framework.aspectj.lang.enums.BusinessType;
import com.ambulance.framework.web.controller.BaseController;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.page.TableDataInfo;
import com.ambulance.project.manager.domain.BizCarChannel;
import com.ambulance.project.manager.service.IBizCarChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车载通道Controller
 *
 * @author zr
 * @date 2020-05-11
 */
@RestController
@RequestMapping("/manager/channel")
public class BizCarChannelController extends BaseController {

    @Autowired
    private IBizCarChannelService bizCarChannelService;

    /**
     * 查询车载通道列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:channel:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizCarChannel bizCarChannel) {
        startPage();
        List<BizCarChannel> list = bizCarChannelService.selectBizCarChannelList(bizCarChannel);
        return getDataTable(list);
    }


    /**
     * 导出车载通道列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:channel:export')")
    @Log(title = "车载通道", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizCarChannel bizCarChannel) {
        List<BizCarChannel> list = bizCarChannelService.selectBizCarChannelList(bizCarChannel);
        ExcelUtil<BizCarChannel> util = new ExcelUtil<BizCarChannel>(BizCarChannel.class);
        return util.exportExcel(list, "channel");
    }

    /**
     * 获取车载通道详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:channel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bizCarChannelService.selectBizCarChannelById(id));
    }

    /**
     * 新增车载通道
     */
    //@PreAuthorize("@ss.hasPermi('manager:channel:add')")
    @Log(title = "车载通道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizCarChannel bizCarChannel) {
        return toAjax(bizCarChannelService.insertBizCarChannel(bizCarChannel));
    }

    /**
     * 修改车载通道
     */
    //@PreAuthorize("@ss.hasPermi('manager:channel:edit')")
    @Log(title = "车载通道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizCarChannel bizCarChannel) {
        return toAjax(bizCarChannelService.updateBizCarChannel(bizCarChannel));
    }

    /**
     * 删除车载通道
     */
    //@PreAuthorize("@ss.hasPermi('manager:channel:remove')")
    @Log(title = "车载通道", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bizCarChannelService.deleteBizCarChannelByIds(ids));
    }
}
